package cn.web.management.service.impl;

import cn.web.management.dao.impl.FindAllImpl;
import cn.web.management.dao.inface.FindAllDao;
import cn.web.management.domain.Salary;
import cn.web.management.service.inface.QuerySalary;
import java.util.List;


public class QuerySalaryImpl implements QuerySalary {

    /**
     * @description: 按月查询个人工资信息
     * @paramName: [employno, date]
     * @paramType: [java.lang.String, java.lang.String]
     * @returnType: java.util.List<cn.web.management.domain.Salary>
     */
    public List<Salary> findSalary(String employno, String date) {

        FindAllDao findAllDao = new FindAllImpl();
        String[] split = date.split(" - ");
        String startTime = split[0]+"-01";
        String endTime = split[1]+"-25";
        List<Salary> personSalary = findAllDao.findPersonSalary(employno, startTime, endTime);
        return personSalary;
    }

    /**
     * @description: 查询个人所有工资信息
     * @paramName: [employno]
     * @paramType: [java.lang.String]
     * @returnType: java.util.List<cn.web.management.domain.Salary>
     */
    public List<Salary> findSalary(String employno) {
        FindAllDao findAllDao = new FindAllImpl();
        List<Salary> personSalary = findAllDao.findPersonSalary(employno);
        return personSalary;
    }

    public String findPayrollDetail(String payroll){
        FindAllDao findAllDao = new FindAllImpl();
        List<Salary> payrollDetail = findAllDao.findPayrollDetail(payroll);
        Salary salary = new Salary();
        salary = payrollDetail.get(0);
        String s = "{";
        s += "\"employno\":\"" + salary.getEmployno()+"\",";
        s += "\"base_salary\":\""+ salary.getBase_salary() +"\",";
        s += "\"working_time\":\""+salary.getWorking_time()+"\",";
        s += "\"bonus\":\""+salary.getBonus()+"\",";
        s += "\"subsidies\":\""+salary.getSubsidies()+"\",";
        s += "\"overtime_salary\":\""+salary.getOvertime_salary()+"\",";
        s += "\"leave_late\":\""+salary.getLeave_late()+"\",";
        s += "\"tax\":\""+salary.getTax()+"\",";
        s += "\"salary_number\":\""+salary.getSalary_number()+"\"";
        s += "}";
        return s;
    }
}
